<div class="bg-light lter b-b wrapper-md">
    <h4 class="m-n font-thin">配送管理</h4>
    <button ui-sref="app.shopDelivery" class="btn-back btn btn-dark btn-sm btn-rounded">
        返回
    </button>
</div>
<div class="wrapper-md" ng-controller="shopDeliveryEditCtrl" ng-init="inint()">
    <div class="panel panel-default">
        <div class="panel-heading m-n">
            修改配送信息
        </div>
        <div class="panel-body">
            <form name="shopDeliveryForm" class="form-horizontal form-validation" ng-submit="edit()">

                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">配送类型</label>
                    <div class="col-sm-5">
                        <select class="form-control" name="type" ng-model="shopDelivery.type" required >
                            <option value="0">一定距离内配送</option>
                            <option value="1">同城配送</option>
                            <option value="2">市内配送</option>
                            <option value="3">省内配送</option>
                            <option value="4">不限</option>
                        </select>
                    </div>
                    <div class="col-sm-5 form-text" ng-if="shopDeliveryForm.name.$touched">
                        <span class="text-danger" ng-if="shopDeliveryForm.name.$error.required">配送类型是选的</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">最小配送距离</label>
                    <div class="col-sm-5">
                        <div class="input-group m-b-xs">
                            <input type="number" class="form-control" name="minDelivery" placeholder="请输入最小配送距离(公里)"  ng-model="shopDelivery.minDelivery " min="0" max="99" maxlength="4" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required>
                            <span class="input-group-addon">公里</span>
                        </div>
                    </div>
                </div>
    
                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">最大配送距离</label>
                    <div class="col-sm-5">
                        <div class="input-group m-b-xs">
                            <input type="number" class="form-control" name="maxDelivery" ng-model="shopDelivery.maxDelivery" min="3" maxlength="7"  placeholder="请输入最大配送距离(公里)" ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required>
                            <span class="input-group-addon">公里</span>
                        </div>
                    </div>
                    <div class="col-sm-5 form-text" ng-if="shopDelivery.minDelivery > shopDelivery.maxDelivery">
                        <span class="text-danger" ng-if="shopDelivery.minDelivery > shopDelivery.maxDelivery">最大配送距离必须大于最小配送距离</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">配送工具</label>
                    <div class="col-sm-5">
                        <select class="form-control" name="vehicle" ng-model="shopDelivery.vehicle" required >
                            <option value="0">步行</option>
                            <option value="1">骑行</option>
                            <option value="2">公交车</option>
                            <option value="3">驾车</option>
                            <option value="4">其他</option>
                        </select>
                    </div>
                    <div class="col-sm-5 form-text" ng-if="shopDeliveryForm.name.$touched">
                        <span class="text-danger" ng-if="shopDeliveryForm.name.$error.required">配送类型是选的</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">配送费用</label>
                    <div class="col-sm-5">
                        <input type="number" name="cost" min="0" max="99" maxlength="2" ng-model="shopDelivery.cost" class="form-control" placeholder="请输入配送费用" required>
                    </div>
                    <div class="col-sm-5 form-text" ng-if="shopDeliveryForm.name.$touched">
                        <span class="text-danger" ng-if="shopDeliveryForm.name.$error.required">配送费用是必填的</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label font-bold">使用门槛</label>
                    <div class="col-sm-5">
                        <div class="m-b-xs">
                            <div class="m-b-sm">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsThreshold" ng-model="shopDelivery.threshold" value="0" required>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">不限制</p>
                            </div>
                            <div ng-if="couponsDetailAddService.coupons.threshold==0">
                                <p class="m-n text-danger">请谨慎设置无门槛配送信息，避免资金损失</p>
                            </div>
                        </div>
                        <div>
                            <div class="inline m-b-sm m-r-xs">
                                <div class="radio inline m-r-n">
                                    <label class="i-checks i-checks-sm">
                                        <input type="radio" name="couponsThreshold" ng-model="shopDelivery.threshold" value="1" required>
                                        <i></i>
                                    </label>
                                </div>
                                <p class="font-bold inline m-n">价格满免</p>
                            </div>
                            <div class="inline" ng-if="shopDelivery.threshold==1">
                                <p class="inline m-r-xs">满</p>
                                <input type="text" min="1" max="99" step="0.01" class="inline w-xs form-control m-r-xs" name="fullPriceReduction" ng-model="shopDelivery.fullPriceReduction"
                                    ng-pattern="/^([1-9][\d]*|0)(\.[\d]{1,2})?$/" required>

                                <p class="inline m-r-xs">元可免配送费</p>
                            </div>
                            <div ng-if="shopDeliveryForm.fullPriceReduction.$touched">
                                <p class="text text-danger" ng-if="shopDeliveryForm.fullPriceReduction.$error.required">
                                    满减价格是必填的</p>

                                <p class="text text-danger" ng-if="shopDeliveryForm.fullPriceReduction.$error.pattern">
                                    请填写正确的价格格式(例:99.99)</p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <button type="submit" class="btn btn-success" ng-disabled="shopDeliveryForm.$invalid">保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>